package cuiyt.datastructure.heap;

import cuiyt.datastructure.searchtree.printer.BinaryTrees;

import java.util.Comparator;

/**
 * @author cyt
 * @describe 测试堆
 * @create 2021-01-10 14:12
 */
public class BinaryHeapTest {

    public static void main(String[] args) {
        BinaryHeap<Integer> h = new BinaryHeap<>();
        h.add(68);
        h.add(72);
        h.add(43);
        h.add(50);
        h.add(38);
        h.add(10);
        h.add(90);
        h.add(65);
        BinaryTrees.print(h);
        System.out.println();
/*        h.remove();
        System.out.println();
        BinaryTrees.print(h);
           h.replace(99);
        System.out.println();
        BinaryTrees.print(h);
        */
        Integer[] data = {68, 72, 43, 50, 38, 10, 90, 65};

        BinaryHeap<Integer> binaryHeap = new BinaryHeap<Integer>(data, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });

        BinaryTrees.print(binaryHeap);
        System.out.println();
    }
}
